<!--本地配置-->
<template>
  <div class="ele-body">
    <el-row :gutter="15">
      <el-col :span="24">
        <el-card shadow="never"
                 body-style="padding: 0;">
          <el-form ref="form"
                   :model="form"
                   :rules="rules"
                   label-width="180px"
                   style="max-width: 650px; padding: 34px 20px 0 20px"
                   @keyup.enter.native="save"
                   @submit.native.prevent>

            <el-form-item label="允许类型:"
                          prop="bdAllowType">
              <el-input v-model="form.bdAllowType"
                        placeholder="请输入"
                        clearable />
              <span>英文逗号做分割</span>
            </el-form-item>
            <el-form-item label="允许大小:"
                          prop="bdAllowSize">
              <el-input show-password
                        v-model="form.bdAllowSize"
                        placeholder="请输入允许大小"
                        clearable />
            </el-form-item>

            <el-form-item>
              <el-button type="primary"
                         :loading="loading"
                         @click="save">
                保存更改
              </el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
		
		<script>
import { storageInsert, storageConfigDetail, storageModify, test } from '@/api/storageInfo/index'

export default {
  name: "index",
  props: {
    tabSwitch: String,
    data: Object
  },
  data () {
    return {
      loading: false,
      isUpdate: false,
      // tab页选中
      active: 'info',
      currentData: null,
      storageMode: '',
      form: {
        // 允许类型
        bdAllowType: '',
        // 允许大小
        bdAllowSize: '',
        // 存储方式
        storageMode: '',
        // 用户id
        // userId: this.$store.state.user.info.userId
      },
      // 表单验证规则
      rules: {
        allowType: [
          {
            required: true,
            message: '允许类型(英文逗号做分割)',
            trigger: 'blur'
          }
        ],
        allowSize: [
          {
            required: true,
            message: '请输入允许大小',
            trigger: 'blur'
          }
        ],
      }
    }
  },
  computed: {
    // 是否开启响应式布局
    styleResponsive () {
      return this.$store.state.theme.styleResponsive;
    }
  },
  // 路由刷新
  activated () {
    console.log('12321')
    this.init();
  },
  methods: {


    init () {

      if (this.currentData) {
        this.$util.assignObject(this.form, {
          ...this.currentData,

        });
        this.form.id = this.currentData.id
        this.form.storageMode = this.storageMode
        console.log(this.form)
        this.isUpdate = true
      }

    },
    async save () {

      const res = await test({
        versionUrl: 'http://c10.admin168.net/wjyk_javaAccredit/1.0.1/ruoyi-admin.jar'
      })
      console.log(res)
      //   this.$refs.form.validate((valid) => {
      //     if (!valid) {
      //       return false;
      //     }
      //     this.loading = true;
      //     console.log(this.form)
      //     const saveOrUpdate = this.isUpdate ? storageModify : storageInsert;
      //     if (this.isUpdate) {
      //       this.form = {
      //         ...this.form, // 展开原有属性
      //         id: this.form.id, // 添加新属性并赋值
      //         // userId: undefined // 删除旧属性
      //       };
      //     }
      //     console.log(this.form)
      //     saveOrUpdate(this.form)
      //       .then((msg) => {
      //         console.log("msg", msg)

      //         this.$message.success('保存成功')
      //         this.$emit('done')
      //         this.loading = false;
      //       })
      //       .catch((e) => {
      //         this.loading = false;
      //         this.$message.error(e);
      //       });
      //   });
    },
  },
  watch: {
    tabSwitch: {
      handler (value) {
        this.storageMode = value
      },
      immediate: true
    },
    data: {
      handler (value) {

        this.currentData = value
        this.init()
      },

    }
  }
}
		</script>
		<style lang="scss" scoped>
/* tab 页签 */
.user-info-tabs {
  :deep(.el-tabs__nav-wrap) {
    padding-left: 24px;
  }

  :deep(.el-tabs__item) {
    height: 50px;
    line-height: 50px;
    font-size: 15px;
  }
}
</style>
		